﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wjtour.BLL;
using Wjtour.Common;
using Wjtour.Domain;
using Hjp.FrameWork.Common;

namespace Wjtour.Web.Admin.article_type
{
    public partial class list : BasePage
    {
        #region 固定分页参数
        private int page = 1;
        private int pagesize = 20;
        #endregion

        articletype_bll _bll = new articletype_bll();
        protected List<Wjtour.Domain.dto.articletype_num> data=new List<Domain.dto.articletype_num>();
        protected TextBox q;
        protected Button submit;
        protected HiddenField delIds;
        protected Button delButton;

        protected void Page_Load(object sender, EventArgs e)
        {
            page = Utils.StrToInt(Request["page"], 1);
            submit.Click += new EventHandler(submit_Click);
            delButton.Click += new EventHandler(delButton_Click);
            bindList();
            if (!IsPostBack)
            {
                q.Text = Request["q"];
            }
        }
       
        void delButton_Click(object sender, EventArgs e)
        {
            bool b = _bll.BatchDelete(delIds.Value) > 0;

            if (b)
            {
                SaveLog("Delete[" + delIds.Value + "]");
                Utils.Alert(this.Page, "删除成功！");
                Utils.Redirect(this.Page, "list.aspx", false);
            }
        }

        void submit_Click(object sender, EventArgs e)
        {
            bindList();
        }

        void bindList()
        {
            data = _bll.GetAll<Wjtour.Domain.dto.articletype_num>(@"select at.*,COUNT(a.id) articlenum from articletype at
                left join article a on at.id=a.cid
                where at.tag='article'
                group by at.id,at.pid,at.sort,at.sys,at.tag,at.title,at.addtime").ToList();
        }
    }
}